int my_create(MINODE* parent, char* fileName)
{
	int i = 0, blockGroup = 0, device = 0;
	ulong fileInode = 0;
	char buf[MAX_BLOCK_SIZE], *pnt = buf;
	EXT2_DISK* diskInfo;
	MINODE* newFile;
	
	/* If the parent is a mounted inode */
	if (parent->mounted == true)
		device = parent->mountedDevice->handle;
	else
		device = parent->location.deviceHandle;
		
	get_device_info(device, &diskInfo);
	
	fileInode = allocate_free_inode(device);
	
	if (fileInode == 0)
		return -1;
	
	/* Load inode into memory */
	newFile = get_inode(device, fileInode);
	if (newFile == 0)
	{
		deallocate_inode(device, fileInode);
		return -1;
	}
	
	/* Fill in data for new inode and write to disk */
	newFile->inode.i_mode = DEFAULT_FILE_MODE;
	newFile->inode.i_uid = runningProc->uid;
	newFile->inode.i_gid = runningProc->gid;
	newFile->inode.i_size = 0;
	newFile->inode.i_links_count = 1;
	newFile->inode.i_atime = newFile->inode.i_ctime = newFile->inode.i_mtime = time(0);
	newFile->inode.i_blocks = 0;
	newFile->dirty = true;
	for (i = 0; i < 15; i++)
		newFile->inode.i_block[i] = 0;
	put_inode(newFile);
	
	/* Write new fileName into parents blocks */
	if (add_name_to_parent(parent, fileInode, fileName) == -1)
	{
		deallocate_inode(device, fileInode);
		return -1;
	}
	
	/* Update parent information and write back to disk */
	parent->inode.i_atime = time(0);
	parent->dirty = true;
	put_inode(parent);
	
	return 1;
}

int do_create(char* pathName)
{
	LOC dirInodeLoc;
	char fullPath[MAX_PATH_LENGTH];
	char dirName[MAX_PATH_LENGTH];
	char baseName[EXT2_MAX_FILE_LENGTH];
	MINODE* dirInode;
	
	if (pathName[0] != '/')
	{
		get_pwd_name(runningProc->cwd, fullPath);
		strcat(fullPath, pathName);
	}
	else
		strcpy(fullPath, pathName);
		
	dir_name(fullPath, dirName);
	base_name(fullPath, baseName);
	
	dirInodeLoc = get_inode_number(dirName);
	if (dirInodeLoc.inodeNum == 0)
	{
		printf("\"%s\" does not exist\n\n", pathName);
		return -1;
	}
	
	dirInode = get_inode(dirInodeLoc.deviceHandle, dirInodeLoc.inodeNum);
	if (dirInode == 0)
		return -1;
		
	if (S_ISDIR(dirInode->inode.i_mode))
	{
		if (search_inode(dirInode, baseName) == 0)
			return my_create(dirInode, baseName);
		
		printf("\"%s\" already exists\n\n", pathName);
		return -1;
	}
	
	printf("\"%s\" is not a directory\n\n", dirName);
	return -1;
}
